import { createApp } from 'vue'

import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

import App from './App.vue'
import router from './router'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

import {useStore} from "@/stores";

const app = createApp(App)

const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);

app.use(pinia);
app.use(router);
app.use(ElementPlus, { locale: zhCn });

app.mount('#app');

// app.directive<HTMLElement, (string | string[])>('auth', (el, binding) => {
//     const store = useStore();
//
//     if(typeof binding.value === 'string' && !store.user.info?.authorities.includes(binding.value) ) {
//         el.style.display = 'none';
//     } else if(binding.value instanceof Array) {
//         let auth = true;
//
//         for(const a of binding.value) {
//             if(!store.user.info?.authorities.includes(a)) {
//                 auth = false;
//                 break;
//             }
//         }
//
//         if(!auth) el.style.display = 'none';
//     }
// });
